/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bionic.socialNet.dao.implementations;

import com.bionic.shsc.dao.interfaces.ICategoryDAO;
import com.bionic.socialNet.entities.TestCategoryData;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author ant
 */
public class MySQLTestCategory extends QueryExecutor implements ICategoryDAO {

    @Override
    public List<TestCategoryData> findAll() {
        try {
            ResultSet RS = query.getRSForQuery("select * from tst_category");
            List<TestCategoryData> res = new ArrayList<TestCategoryData>();
            while (RS.next()) {
                TestCategoryData tc = new TestCategoryData();
                tc.setId(RS.getInt("category_id"));
                tc.setName(RS.getString("category_name"));
                tc.setDescription(RS.getString("description"));
                res.add(tc);
            }
            return res;
        } catch (SQLException ex) {
            Logger.getLogger(MySQLUser.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
}
